<!--
 * @Description: What's this for
 
 * @Date: 2021-10-08 15:37:03
 
 * @LastEditTime: 2021-10-25 16:19:21
-->
<template>
  <!-- <config-item :label="label"> -->
  <config-item :label="label">
    <GoodsConfigList :value="mValue" @edit="edit(mValue)"></GoodsConfigList>
    <AddProductList ref="addProductList" @submit="replace"></AddProductList>
    <!-- <GoodsConfigChoose
      v-if="show"
      ref="abc"
      :show.sync="show"
      :value="mValue"
      @submit="replace"
    >
    </GoodsConfigChoose> -->
  </config-item>
</template>

<script>
import ConfigItem from "../../../components/global/ConfigItem.vue";
import AddProductList from "@/components/Control/addProductList.vue";
import schemaMixin from "@/mixin/schemaMixin";

export default {
  name: "SchemaGoods",

  components: { ConfigItem, AddProductList },

  inject: ["control"],

  mixins: [schemaMixin],

  props: {
    value: {
      type: Array,
      default: () => [],
    },
  },

  data() {
    return {
      show: false,
      mValue: [],
    };
  },

  watch: {
    value: {
      immediate: true,
      handler(newValue, oldValue) {
        this.mValue = newValue;
      },
    },

    mValue: {
      immediate: true,
      deep: true,
      handler(newValue, oldValue) {
        this.$emit("input", newValue);
      },
    },
  },

  methods: {
    edit(mValue) {
      // mValue = mValue.join(",");
      // let list = this.control.curPage.componentList;
      // let id = "";
      // list.forEach((item) => {
      //   if (item.component == "McGoods" && item.goodsData.length > 0) {
      //     // localStorage.setItem(key, value);
      //     // if(item.goodsData[0].list){
      //     // id=item.goodsData[0].list.split(",")
      //     // }
      //   } else {
      //     id = "";
      //   }
      // });
      // console.log("点击产品列表", item, this.control.curPage.componentList);
      // let id = this.$store.getters.data().CurPage.id;
      // if (id) {
      //   // this.show = true;
      //   // const a = JSON.parse(JSON.stringify(this.$refs))
      //   // console.log("kk", a, a.abc);
      //   // this.$refs.abc.getList(id);
      //   console.log("进");
      this.$refs.addProductList.open(mValue);
      // } else {
      //   this.$message.error("请选择分销商！");
      // }
    },

    replace(ids) {
      this.mValue = ids;
      console.log("修改", ids);
    },
  },
};
</script>

<style lang="scss" scoped></style>
